/**
 * Alipay.com Inc.
 * Copyright (c) 2004-2011 All Rights Reserved.
 */
package com.alipay.supergw.common.dal.share_supergw.auto.ibatis;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.alipay.supergw.common.dal.share_supergw.auto.daointerface.CommunicationMapDAO;
import com.alipay.supergw.common.dal.share_supergw.auto.dataobject.CommunicationMapDO;

/**
 * An ibatis based implementation of dao interface <tt>com.alipay.supergw.common.dal.share_supergw.auto.daointerface.CommunicationMapDAO</tt>.
 *
 * This file is generated by <tt>supergw-dalgen</tt>, a DAL (Data Access Layer)
 * code generation utility specially developed for <tt>supergw</tt> project.
 * 
 * PLEASE DO NOT MODIFY THIS FILE MANUALLY, or else your modification may
 * be OVERWRITTEN by someone else. To modify the file, you should go to 
 * directory <tt>(project-home)/dalgen</tt>, and 
 * find the corresponding configuration file (<tt>tables/sgw_communication_map.xml</tt>). 
 * Modify the configuration file according to your needs, then run <tt>supergw-dalgen</tt> 
 * to generate this file.
 */
public class IbatisCommunicationMapDAO extends SqlMapClientDaoSupport implements
                                                                     CommunicationMapDAO {

    /**
     *  Query DB table <tt>sgw_communication_map</tt> for records.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>select out_trans_code_id, communication_id, charset, recv_data_type, send_data_type, send_buf_size, recv_buf_size, uri, timeout, properties, gmt_create, gmt_modified from sgw_communication_map where (communication_id = ?)</tt>
     *
     *	@param communicationId
     *	@return List<CommunicationMapDO>
     *	@throws DataAccessException
     */
    @SuppressWarnings("unchecked")
    public List<CommunicationMapDO> loadByCommunicationId(String communicationId)
                                                                                 throws DataAccessException {

        return getSqlMapClientTemplate().queryForList(
            "MS-COMMUNICATION-MAP-LOAD-BY-COMMUNICATION-ID", communicationId);

    }

    /**
     *  Query DB table <tt>sgw_communication_map</tt> for records.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>select out_trans_code_id, communication_id, charset, recv_data_type, send_data_type, send_buf_size, recv_buf_size, uri, timeout, properties, gmt_create, gmt_modified from sgw_communication_map</tt>
     *
     *	@return List<CommunicationMapDO>
     *	@throws DataAccessException
     */
    @SuppressWarnings("unchecked")
    public List<CommunicationMapDO> loadAll() throws DataAccessException {

        return getSqlMapClientTemplate().queryForList("MS-COMMUNICATION-MAP-LOAD-ALL", null);

    }

    /**
     *  Query DB table <tt>sgw_communication_map</tt> for records.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>select out_trans_code_id, communication_id, charset, recv_data_type, send_data_type, send_buf_size, recv_buf_size, uri, timeout, properties, gmt_create, gmt_modified from sgw_communication_map where ((communication_id = ?) AND (out_trans_code_id = ?))</tt>
     *
     *	@param communicationId
     *	@param outTransCodeId
     *	@return CommunicationMapDO
     *	@throws DataAccessException
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
    public CommunicationMapDO selectByCommunicationIdAndOutTransCodeId(String communicationId,
                                                                       String outTransCodeId)
                                                                                             throws DataAccessException {
        Map param = new HashMap();

        param.put("communicationId", communicationId);
        param.put("outTransCodeId", outTransCodeId);

        return (CommunicationMapDO) getSqlMapClientTemplate().queryForObject(
            "MS-COMMUNICATION-MAP-SELECT-BY-COMMUNICATION-ID-AND-OUT-TRANS-CODE-ID", param);

    }

    /**
     *  Query DB table <tt>SGW_COMMUNICATION_MAP</tt> for records.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>select out_trans_code_id, charset, recv_data_type, send_data_type, send_buf_size, recv_buf_size, gmt_create, gmt_modified, communication_id, properties, uri, timeout from sgw_communication_map where ((communication_id = ?) AND (out_trans_code_id = ?))</tt>
     *
     *  @param communicationId
     *  @param outTransCodeId
     *  @return List<CommunicationMapDO>
     *  @throws DataAccessException
     */
    @SuppressWarnings( { "rawtypes", "unchecked" })
    public List<CommunicationMapDO> select(String communicationId, String outTransCodeId)
                                                                                         throws DataAccessException {
        Map param = new HashMap();

        param.put("communicationId", communicationId);
        param.put("outTransCodeId", outTransCodeId);

        return getSqlMapClientTemplate().queryForList("MS-COMMUNICATION-MAP-SELECT", param);

    }

    /**
     *  Query DB table <tt>sgw_communication_map</tt> for records.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>select out_trans_code_id, communication_id, charset, recv_data_type, send_data_type, send_buf_size, recv_buf_size, uri, timeout, properties, gmt_create, gmt_modified from sgw_communication_map where (communication_id = ?)</tt>
     *
     *	@param communicationId
     *	@return List<CommunicationMapDO>
     *	@throws DataAccessException
     */
    @SuppressWarnings("unchecked")
    public List<CommunicationMapDO> selectByCommunicationId(String communicationId)
                                                                                   throws DataAccessException {

        return getSqlMapClientTemplate().queryForList(
            "MS-COMMUNICATION-MAP-SELECT-BY-COMMUNICATION-ID", communicationId);

    }

    /**
     *  Insert one <tt>CommunicationMapDO</tt> object to DB table <tt>sgw_communication_map</tt>, return primary key
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>insert into sgw_communication_map(out_trans_code_id,communication_id,charset,recv_data_type,send_data_type,send_buf_size,recv_buf_size,uri,timeout,properties,gmt_create,gmt_modified) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate, sysdate)</tt>
     *
     *	@param communicationMap
     *	@return int
     *	@throws DataAccessException
     */
    public String insert(CommunicationMapDO communicationMap) throws DataAccessException {
        if (communicationMap == null) {
            throw new IllegalArgumentException("Can't insert a null data object into db.");
        }

        getSqlMapClientTemplate().insert("MS-COMMUNICATION-MAP-INSERT", communicationMap);

        return communicationMap.getCommunicationId();
    }

    /**
     *  Update DB table <tt>sgw_communication_map</tt>.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>update sgw_communication_map set charset=?, recv_data_type=?, send_data_type=?, send_buf_size=?, recv_buf_size=?, uri=?, timeout=?, properties=?, gmt_modified=sysdate where ((communication_id = ?) AND (out_trans_code_id = ?))</tt>
     *
     *	@param charset
     *	@param recvDataType
     *	@param sendDataType
     *	@param sendBufSize
     *	@param recvBufSize
     *	@param uri
     *	@param timeout
     *	@param properties
     *	@param communicationId
     *	@param outTransCodeId
     *	@return int
     *	@throws DataAccessException
     */
    @SuppressWarnings( { "rawtypes", "unchecked" })
    public int update(String charset, String recvDataType, String sendDataType, int sendBufSize,
                      int recvBufSize, String uri, String timeout, String properties,
                      String communicationId, String outTransCodeId) throws DataAccessException {
        Map param = new HashMap();

        param.put("charset", charset);
        param.put("recvDataType", recvDataType);
        param.put("sendDataType", sendDataType);
        param.put("sendBufSize", new Integer(sendBufSize));
        param.put("recvBufSize", new Integer(recvBufSize));
        param.put("uri", uri);
        param.put("timeout", timeout);
        param.put("properties", properties);
        param.put("communicationId", communicationId);
        param.put("outTransCodeId", outTransCodeId);

        return getSqlMapClientTemplate().update("MS-COMMUNICATION-MAP-UPDATE", param);
    }

    /**
     *  Delete records from DB table <tt>sgw_communication_map</tt>.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>delete from sgw_communication_map where ((communication_id = ?) AND (out_trans_code_id = ?))</tt>
     *
     *	@param communicationId
     *	@param outTransCodeId
     *	@return int
     *	@throws DataAccessException
     */
    @SuppressWarnings( { "rawtypes", "unchecked" })
    public int delete(String communicationId, String outTransCodeId) throws DataAccessException {
        Map param = new HashMap();

        param.put("communicationId", communicationId);
        param.put("outTransCodeId", outTransCodeId);

        return getSqlMapClientTemplate().delete("MS-COMMUNICATION-MAP-DELETE", param);
    }

}